/**
 * Created by renzhiqiang on 17/4/25.
 */
import { Layout, Menu, Breadcrumb, Icon, Input, Row, Col, Dropdown} from 'antd';
import React, {PropTypes} from 'react'

import connect from 'dva';
import style from './home.less';
const { Header} = Layout;
const Search = Input.Search;
function header({dispatch}) {
  var useName = '';
  var clickImg = () => {
    dispatch({
      type: 'home/isShow',
      preload:{
        id:1
      }
    })
  };
  var emitEmpty = () => {
    useName = '';
  };
  var onChangeUserName = (value) => {
    useName = value;
  };
  const menu = (
    <Menu>
      <Menu.Item>
        <a target="_blank" rel="noopener noreferrer" href="http://www.alipay.com/">1st menu item</a>
      </Menu.Item>
      <Menu.Item>
        <a target="_blank" rel="noopener noreferrer" href="http://www.taobao.com/">2nd menu item</a>
      </Menu.Item>
      <Menu.Item>
        <a target="_blank" rel="noopener noreferrer" href="http://www.tmall.com/">3d menu item</a>
      </Menu.Item>
    </Menu>
  );
  var logout = () => {
    location.href = "/login";
  };
  const menuOne = (
    <Menu>
      <Menu.Item>
        <a onClick={logout}>退出</a>
      </Menu.Item>
      <Menu.Item>
        <a  onClick={logout}>注销</a>
      </Menu.Item>
    </Menu>
  );
  const suffix = useName ? <Icon type="close-circle" onClick={emitEmpty} /> : null;
  const imgError = (e)=>{
    // e.target.src = '';
    e.target.src = '';
  }

  const setDefaultUrl = ()=> ''

  return (
  <Header className={style.ht}>
    <div>
      <Row type="flex" justify="space-around" align="middle">
        <Col span={8}>
        <div className={style.disp} onClick={clickImg}>
          <Icon type="menu-fold" className={style.white} />
        </div>
        <div className={style.disp}>
          <Search
            placeholder="input search text"
            style={{ width: 300 }}
            onSearch={value => console.log(value)}
          />
        </div>
        </Col>
        <Col span={1} offset={12}>
          <Dropdown placement="bottomCenter" overlay={menu}>
           <span className={style.square}>
                  <Icon type="plus-square" />
          </span>
          </Dropdown>
        </Col>
        <Col span={1} className={style.setUp}>
          <Icon type="tool" />
        </Col>
          <Dropdown overlay={menuOne} trigger={['click']}>
            <div style={{overflow:'hidden', height:'100%'}}>
              <div className={style.usrNamePost}>
                <p>网上</p>
                <p>经理</p>
              </div>{/*http://www.qqxoo.com/uploads/*/}
              <img className={style.usrHead} src={setDefaultUrl()} onError={imgError}/>
            </div>
          </Dropdown>
      </Row>
    </div>,

      </Header>
  )
}
export default header;


